package com.kaiyidiannao.db;

import android.content.Context;
import android.database.DatabaseErrorHandler;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class RpcCacheDBHelper extends SQLiteOpenHelper{
	public static final int DB_RPC_CHCHE_VERSION = 1;
	public static final String DB_RPC_CHCHE_TABLE_NAME = "kaiyi_diannao_cache_tb";
	private final String DB_RPC_CHCHE_CREATE_SQL = "CREATE TABLE " + DB_RPC_CHCHE_TABLE_NAME + " " +
			"(`key` varchar(32) NOT NULL," +
			"`body` text," +
			"`time` varchar(20))";
	private final String DB_RPC_CHCHE_CLEAR_SQL = "DELETE FROM " + DB_RPC_CHCHE_TABLE_NAME + "IF EXISTS";
	

	public RpcCacheDBHelper(Context context, String name, CursorFactory factory, int version, DatabaseErrorHandler errorHandler) {
		super(context, name, factory, version, errorHandler);
	}

	public RpcCacheDBHelper(Context context, String name, CursorFactory factory, int version) {
		super(context, name, factory, version);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(DB_RPC_CHCHE_CREATE_SQL);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		db.execSQL(DB_RPC_CHCHE_CLEAR_SQL);
	}
	
}
